<template name="MailgunMenuItem">
  {{#if compare currentUser.isAdmin '&&' (count 'mailgun')}}
    <li class="{{#if inRouter 'mailgun'}}active{{/if}}">
      <a href="/mailgun">
        <i class="fa fa-envelope"></i> <span>{{_ "Emails TODO"}}</span>
        {{#if (count 'mailgun')}}
          <span class="pull-right-container">
            <span class="label label-danger pull-right">{{count 'mailgun'}}</span>
          </span>
        {{/if}}
      </a>
    </li>
  {{/if}}
</template>

<template name="MailgunEmails">
  {{#contentFor "menu"}}
    <p class="navbar-text pull-left menu-title">{{_ "Emails TODO"}}</p>
  {{/contentFor}}

  <ul class="list-group threads">
    {{#each emails}}
      <li class="list-group-item thread" data-id="{{_id}}">
        <div class="btn-group email-actions pull-right">
          <button type="button" class="btn btn-default btn-sm btn-parse">{{_ "Parse"}}</button>
          <button type="button" class="btn btn-default btn-sm btn-remove">{{_ "Drop"}}</button>
        </div>
        {{#with params}}
          <div>Subject: <a href="#" class="btn-preview">{{subject}}</a></div>
          <div>From: {{from}}</div>
          <div>To: {{To}}</div>
        {{/with}}
        <div>Time: {{createdAt}}</div>
        {{#with error}}<pre style="margin: 5px 0 0;">{{this}}</pre>{{/with}}
      </li>
    {{/each}}
    {{#unless emails.count}}
      <li class="list-group-item thread">{{_ "app_no_record"}}</li>
    {{/unless}}
  </ul>
</template>
